import { $post, $get, $put, $delete } from './http'

// 用户登录
export const userLoginReq = userInfo => $post('/login', userInfo)

// 获取用户列表
export const getUserListReq = params => $get('/users', params)

// 修改用户状态
export const editUserStatusReq = (uId, type) =>
  $put(`/users/${uId}/state/${type}`)

// 为用户分配角色
export const editUserRoleReq = (id, rid) => $put(`users/${id}/role`, { rid })

// 添加或编辑用户
export const addOrEditUserReq = (id, user) =>
  id ? $put(`/users/${id}`, user) : $post('/users', user)

// 删除用户
export const deleteUserReq = id => $delete(`users/${id}`)
